import {parser} from "xijs";
import {store} from "@/js/store";

export const roomJson =(all)=>{
    let lCardList=[...store.state.cardList]
    if (!(all??false))lCardList = lCardList.filter((ele)=>{return ele.PLVisible})
    let room={
        cardList:lCardList
    }
    return parser.stringify(room)
}
export const readRoom =(json,localRead)=>{
    let room=parser.parse(json)
    if (room==null)return
    if (localRead)room[localRead]=true
    if (room.cardList!=null){
        store.commit('initRoom',room)
    }
}
export const emptyRoom=()=>{
    store.commit('initRoom',{localRead:true,cardList:[]})
}
